#pragma once

#include "../Datasources/WavFileSampleReader.h"
#include "../Datasources/FolderReader.h"
#include "../Classifiers/DTW.h"
#include "../Classifiers/ChaineApprentissage.h"
#include "../FeatureProcessing/Preaccentuation.h"
#include "../FeatureProcessing/Normalisation.h"
#include "../FeatureProcessing/Labelisation.h"
#include "../FeatureProcessing/MFCC.h"
#include "../FeatureProcessing/DistanceFrameDeletion.h"
#include "../FeatureProcessing/SegmentationParole.h"
#include "../Entities/Array.h"
#include "../Utilities/MatlabProcess.h"
#include "../Utilities/TagRule.h"
#include "../Outputs/ResultConsoleWriter.h"
#include "../Outputs/ResultFileWriter.h"
#include "../Outputs/TextFormatting.h"
#include "../Outputs/TextFormatting.h"
#include "ProgressRecognition.h"

using namespace DataSources;
using namespace Classifiers;
using namespace FeatureProcessing;
using namespace Entities;
using namespace Utilities;
using namespace Outputs;

class ChaineDTW : public ChaineApprentissage {
protected :
	WavFileSampleReader::type_pointer wavFile;

public:
	ChaineDTW(string _baseA, string _baseT, string _dest, Array<TagRule> & _rules ,bool _resize = true, 
		bool _normalize = false, int _nbCoeffs = 3, int _nbSamplesPerFrame = 80, int _nbFiltres = 10, int _nbFrames = 35):
		ChaineApprentissage(new DTW){
	
		wavFile = new WavFileSampleReader;
		setTrainingReader(new FolderReader(wavFile, _baseA));
		setReader(new FolderReader(wavFile, _baseT));
		addProcessor(new Filtres::Preaccentuation);
		//addProcessor(new Segmentations::SegmentationParole(80, 10, 0.003, 15, 2, 0, 0));
		if (_normalize) addProcessor(new Normalisation);
		addProcessor(new Labelisation(_rules));
		addProcessor(new MFCC(_nbCoeffs, _nbSamplesPerFrame, _nbFiltres));
		if (_resize) addProcessor(new Redimensionnement::DistanceFrameDeletion(_nbFrames));
		ResultFormattingPtr formatting = new TextFormatting();
		addListener(new ProgressRecognition(reader->getLen()));
		setWriter(new ResultFileWriter(formatting, _dest));
	}

	void train(){
		ChaineApprentissage::train();
	}

	void recognize(){
		ChaineApprentissage::recognize();
	}
};
